package edu.shiep.sunyu.model;

import com.mongodb.BasicDBObject;

public class Bus implements BaseDBObj {
	
	public static final String Field_Id = "id";
	public static final String Field_Line = "line";
	public static final String Field_Seat = "seat";
	public static final String Field_Reserve = "reserve";
	public static final String Field_Ahead = "ahead";
	
	public Bus() {
		
	}
	
	public void deserialize(BasicDBObject obj) {
		_id = obj.getString(Field_Id);
		_line = obj.getString(Field_Line);
		_seat = Integer.parseInt(obj.getString(Field_Seat));
		_reserve = Integer.parseInt(obj.getString(Field_Reserve));
		_ahead = Integer.parseInt(obj.getString(Field_Ahead));
	}
	
	public BasicDBObject serialize() {
		return new BasicDBObject(Field_Id, this._id).
				append(Field_Line, this._line).
				append(Field_Seat, this._seat).
				append(Field_Reserve, this._reserve).
				append(Field_Ahead, this._ahead);
	}
	
	public void setId(String _id) {
		this._id = _id;
	}
	
	public String getId() {
		return this._id;
	}
	
	public void setLine(String _line) {
		this._line = _line;
	}
	
	public String getLine() {
		return this._line;
	}
	
	public void setSeat(int _seat) {
		this._seat = _seat;
	}
	
	public int getSeat() {
		return this._seat;
	}
	
	public void setReserve(int _reserve) {
		this._reserve = _reserve;
	}
	
	public int getReserve() {
		return this._reserve;
	}
	
	public void setAhead(int _ahead) {
		this._ahead = _ahead;
	}
	
	public int getAhead() {
		return this._ahead;
	}
	
	private String _id = "";
	private String _line = "";
	private int _seat = 0;
	private int _reserve = 0;
	private int _ahead = 0;
	
}
